package examples;

import java.util.*;
/**
 * Write a description of class TowerState here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Tower
{
    private ArrayList<Integer> chosen;
    private ArrayList<Integer> remaining;
    private int height;
    
    public Tower(int[] blocks)
    {
        chosen = new ArrayList<Integer>();
        remaining = new ArrayList<Integer>();
        for (int n : blocks) {
            remaining.add(n);
        }
        height = 0;
    }
    
    public Tower copy()
    {
        Tower t = new Tower(new int[] {});
        t.chosen = new ArrayList<Integer>(chosen);
        t.remaining = new ArrayList<Integer>(remaining);
        t.height = height;
        return t;
    }
        
    
    public ArrayList<Integer> getRemaining()
    {
        return remaining;
    }
    
    public Tower choose(int n) {
        Tower t = copy();
        if (t.remaining.contains(n)) {
            t.remaining.remove(new Integer(n));
            t.chosen.add(n);
            t.height += n;
        }
        return t;
    }
    
    public int getHeight()
    {
        return height;
    }
    
    public String toString()
    {
        String s = "";
        for (int n : chosen) {
            s += " " + n;
        }
        s += " | ";
        for (int n : remaining) {
            s += " " + n;
        }
        return s;
    }
}
